﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Community.CsharpSqlite
{
    class SqliteInt
    {

        /*
** FTS4 is really an extension for FTS3.  It is enabled using the
** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all
** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
*/
        //#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
        //# define SQLITE_ENABLE_FTS3
        //#endif

        /*
    ** The ctype.h header is needed for non-ASCII systems.  It is also
    ** needed by FTS3 when FTS3 is included in the amalgamation.
    */
        //#if !defined(SQLITE_ASCII) || \
        //    (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))
        //# include <ctype.h>
        //#endif


        /*
    ** The following macros mimic the standard library functions toupper(),
    ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
    ** sqlite versions only work for ASCII characters, regardless of locale.
    */
#if SQLITE_ASCII
        //# define sqlite3Toupper(x)  ((x)&~(Global.Sqlite3CtypeMap[(unsigned char)(x)]&0x20))

        //# define SqliteInt.Sqlite3Isspace(x)   (Global.Sqlite3CtypeMap[(unsigned char)(x)]&0x01)
        public static bool Sqlite3Isspace(byte x)
        {
            return (Global.Sqlite3CtypeMap[(x)] & 0x01) != 0;
        }

        public static bool Sqlite3Isspace(char x)
        {
            return x < 256 && (Global.Sqlite3CtypeMap[(byte)(x)] & 0x01) != 0;
        }

        //# define sqlite3Isalnum(x)   (Global.Sqlite3CtypeMap[(unsigned char)(x)]&0x06)
        public static bool Sqlite3Isalnum(byte x)
        {
            return (Global.Sqlite3CtypeMap[(x)] & 0x06) != 0;
        }

        public static bool Sqlite3Isalnum(char x)
        {
            return x < 256 && (Global.Sqlite3CtypeMap[(byte)(x)] & 0x06) != 0;
        }

        //# define sqlite3Isalpha(x)   (Global.Sqlite3CtypeMap[(unsigned char)(x)]&0x02)

        //# define SqliteInt.Sqlite3Isdigit(x)   (Global.Sqlite3CtypeMap[(unsigned char)(x)]&0x04)
        public static bool Sqlite3Isdigit(byte x)
        {
            return (Global.Sqlite3CtypeMap[(x)] & 0x04) != 0;
        }

        public static bool Sqlite3Isdigit(char x)
        {
            return x < 256 && (Global.Sqlite3CtypeMap[((byte)x)] & 0x04) != 0;
        }

        //# define sqlite3Isxdigit(x)  (Global.Sqlite3CtypeMap[(unsigned char)(x)]&0x08)
        public static bool Sqlite3Isxdigit(byte x)
        {
            return (Global.Sqlite3CtypeMap[(x)] & 0x08) != 0;
        }

        public static bool Sqlite3Isxdigit(char x)
        {
            return x < 256 && (Global.Sqlite3CtypeMap[((byte)x)] & 0x08) != 0;
        }

        //# define sqlite3Tolower(x)   (Global.Sqlite3UpperToLower[(unsigned char)(x)])
#else
//# define sqlite3Toupper(x)   toupper((unsigned char)(x))
//# define SqliteInt.Sqlite3Isspace(x)   isspace((unsigned char)(x))
//# define sqlite3Isalnum(x)   isalnum((unsigned char)(x))
//# define sqlite3Isalpha(x)   isalpha((unsigned char)(x))
//# define SqliteInt.Sqlite3Isdigit(x)   isdigit((unsigned char)(x))
//# define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))
//# define sqlite3Tolower(x)   tolower((unsigned char)(x))
#endif

    }
}
